source(here::here("code/load.R"))

bib = here("data/meta_analyses_raw/BlaChrRud2020/replication/data/bibliography-df.csv") |>
    read_csv() |>
    mutate(study_id = tolower(bib_bibtexkey),
           bib_year = ifelse(bib_bibtexkey == "McGuirk_Burke", "2020", bib_year),
           bib_year = as.numeric(bib_year)) |>
    select(study_id, study_year = bib_year)

here("data/meta_analyses_raw/BlaChrRud2020/replication/data/meta-df.csv") |>
    read_csv() |>
    #they filter out the following in their analysis (fig-1-effect-sizes.R)
    filter(commodity_type != "Drugs",
           !(outcome_type %in% c("Protest", "Coups")),
           partial_r_only == 0) |>
    # head(2) |> data.frame()
    mutate(meta_id = "BlaChrRud2020",
           question = "Do commodity price shocks cause armed conflict?",
           overall_effect = "no",
           subfield = "CP") |>  
    select(meta_id,
           subfield,
           question,
           study_id,
           estimate = std_effect_cov,
           std.error = std_se_cov,
           subset = commodity_type,
           overall_effect) |>
    left_join(bib, by = "study_id") |>
    unique() |>
    write_csv(here("data/meta_analyses_clean/BlaChrRud2020.csv"))
